<?php

function smarty_block_highlight($params, $content, $template, &$repeat)
{
   if (isset($content) && $params['words'])
   {
      $words = trim($params['words']);
      $words = str_replace('[','\[',$words);
      $words = str_replace(']','\]',$words);
      $words = preg_replace('/([ ])+/', ' ', $words);
      $words = preg_replace('/([^ ]+)/', '/$1/i', $words);

      $words = explode(' ',$words);
      return preg_replace($words, '<span class=highlight>$0</span>', $content);
   }
   return $content;
}

?>